//
//  ContactManager.m
//  04-集合2
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ContactManager.h"

@implementation ContactManager
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
    self = [super init];
    if (self) {
        _contactDictionary = dictionary;
    }
    return self;
}
- (void)addContact:(Contact *)contact {
    if (contact.name.length > 0 && contact.phoneNumber.length > 0) {
        NSMutableArray *contactArr = [_contactDictionary objectForKey:contact.groupName];
        if (contactArr == nil) {
            contactArr = [NSMutableArray arrayWithObject:contact.groupName];
        } else {
            [contactArr addObject:contact];
        }
        NSLog(@"添加联系人成功",contact.name);
        
    } else {
        NSLog(@"添加联系人失败",contact.name);

    }
}
- (void)removeContact:(Contact *)contact {
    
}
- (void)removeGroupWithName:(NSString *)groupName {
    [_contactDictionary removeObjectForKey:groupName];
}

@end
